package cn.tac.test.spring.aop.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author : tac
 * @date : 16/04/2017
 */

@Aspect
public class AnnotationAudience {
    private Logger logger = LoggerFactory.getLogger(this.getClass());



    @Pointcut("execution(* cn.tac.test.spring.aop.bean.Actor.perform())")
    public void pointcut(){
    }

    @Pointcut("execution(* cn.tac.test.spring.aop.bean.Actor.performWithArgs(String, String)) && args(name, arg2)")
    public void pointcut1(String name, String arg2){}


    @Before("pointcut()")
    public void beforePerform(){
        logger.info("the audience are applaud for the actor by annotation aspect");
    }

    @After("pointcut()")
    public void afterPerform(){
        logger.info("the audience are applaud for the performance by annotation aspect");
    }

    @Around("pointcut1(name, arg2)")
    public void aroundPerform(ProceedingJoinPoint joinPoint, String name, String arg2){
        logger.info("the audience are applaud for the actor by annotation aspect~");

        try {
            joinPoint.proceed();
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
        logger.info("the audience are applaud for the performance by annotation aspect~");
    }

}
